<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>运行中的流程</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function(){
			top.$.jBox.tip.mess = null;
			layui.use(['laypage', 'form'], function(){
				var form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功
				form.render();
				var laypage = layui.laypage;
				laypage.render({elem:'pageDiv',
					count: ${page.count}, //数据总数，从服务端得到
					curr:${page.pageNo},
					limit:30,
					layout: ['prev', 'page', 'next', 'count'],
					jump: function(obj, first){
					//obj包含了当前分页的所有参数，比如：
					 // console.log(obj.curr); //得到当前页，以便向服务端请求对应页的数据。
					 // console.log(obj.limit); //得到每页显示的条数
					
					//首次不执行
						if(!first){
							$("#firstPage").val(false);
							page(obj.curr,obj.limit);
						}
					}
				});
				var table = layui.table;
				table.init('runningTable',{limit:30});
			});
		});
		function page(n,s){
        	location = '${ctx}/act/process/running/?pageNo='+n+'&pageSize='+s;
        }
		function updateCategory(id, category){
			$.jBox($("#categoryBox").html(), {title:"设置分类", buttons:{"关闭":true}, submit: function(){}});
			$("#categoryBoxId").val(id);
			$("#categoryBoxCategory").val(category);
		}
	</script>
	<script type="text/template" id="categoryBox">
		<form id="categoryForm" action="${ctx}/act/process/updateCategory" method="post" enctype="multipart/form-data"
			style="text-align:center;" class="form-search" onsubmit="loading('正在设置，请稍等...');"><br/>
			<input id="categoryBoxId" type="hidden" name="procDefId" value="" />
			<select id="categoryBoxCategory" name="category">
				<c:forEach items="${fns:getDictList('act_category')}" var="dict">
					<option value="${dict.value}">${dict.label}</option>
				</c:forEach>
			</select>
			<br/><br/>　　
			<input id="categorySubmit" class="btn btn-primary" type="submit" value="   保    存   "/>　　
		</form>
	</script>
</head>
<body>
	<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
		<ul class="layui-tab-title">
		<li><a href="${ctx}/act/process/">流程管理</a></li>
		<li><a href="${ctx}/act/process/deploy/">部署流程</a></li>
		<li class="layui-this"><a href="${ctx}/act/process/running/">运行中的流程</a></li>
	</ul></div>
	<form id="searchForm" action="${ctx}/act/process/running/" method="post" class="layui-form">
	<blockquote class="layui-elem-quote quoteBox">
		<div class="layui-inline">
			<label class="layui-form-label" >流程实例ID：</label>
			<div class="layui-input-inline">
				<input type="text" id="procInsId" name="procInsId" value="${procInsId}" class="layui-input"/>
			</div>
		</div>
		<div class="layui-inline">
			<label class="layui-form-label" style="width:auto;">流程定义key：</label>
			<div class="layui-input-inline">
				<input type="text" id="procDefKey" name="procDefKey" value="${procDefKey}" class="layui-input"/>
			</div>
		</div>
		<div class="layui-inline">
		&nbsp;<input id="btnSubmit" class="layui-btn search_btn" type="submit" value="查询"/>
		</div>
	</blockquote>
	</form>
	<sys:message content="${message}"/>
	<table class="layui-table" lay-filter="runningTable">
		<thead>
			<tr>
				<th lay-data="{field:'todoId', minWidth:100}">执行ID</th>
				<th lay-data="{field:'modelId', minWidth:100}">流程实例ID</th>
				<th lay-data="{field:'proId', minWidth:100}">流程定义ID</th>
				<th lay-data="{field:'nowTod', minWidth:100}">当前环节</th>
				<th lay-data="{field:'isUp', minWidth:90}">是否挂起</th>
				<th lay-data="{field:'todoFlag', minWidth:90, fixed:'right'}">操作</th>
			</tr>
		</thead>
		<tbody>
			<c:forEach items="${page.list}" var="procIns">
				<tr>
					<td>${procIns.id}</td>
					<td>${procIns.processInstanceId}</td>
					<td>${procIns.processDefinitionId}</td>
					<td>${procIns.activityId}</td>
					<td>${procIns.suspended?'是':'否'}</td>
					<td>
						<shiro:hasPermission name="act:process:edit">
							<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"
							 href="${ctx}/act/process/deleteProcIns?procInsId=${procIns.processInstanceId}&reason=" onclick="return promptx('删除流程','删除原因',this.href);">删除流程</a>
						</shiro:hasPermission>&nbsp;
					</td>
				</tr>
			</c:forEach>
		</tbody>
	</table>
	<div id="pageDiv" class="pagination layui-elem-field layui-field-title">${page}</div>
</body>
</html>
